home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
compuserve-file-archive
/
08 System Utilities
/
LRR200.SFX
/
lrr200.asm
< prev
next >
Wrap
Assembly Source File
|
1990-02-12
|
25KB
|
1,448 lines
; ╠ITTLE ╥ED ╥EADER/╫RITER UTILITY PACKAGE BY ├RAIG ┬RUCE, 31-╩AN-92
; ╫RITTEN FOR ├= ╚ACKING ╬ET-═AGAZINE; FOR ├-128, 1571, 1581
; ╒PGRADED FOR ╞─-2000/4000 ╚IGH ─ENSITY ═╙-─╧╙ DISKS, 08-═AR-94
.ORG $5000
.OBJ "@0:LRR.BIN"
;====JUMP TABLE AND PARAMETERS INTERFACE ====
JMP INIT╨ACKAGE ;()
JMP MS─IR ;( MS─EVICE, MS╘YPE ) : .┴┘=DIR┴DDR, .╪=DIRENT├OUNT
JMP MS╥EAD ;( MS─EVICE, MS╘YPE, START├LUSTER, LEN═╠,.┴=TRANS,.╪=CBM╠FN )
JMP MS╫RITE ;( MS─EVICE, MS╘YPE, WRITE─IRENT, .┴=TRANS, .╪=CBM╠FN )
JMP MS╞LUSH ;( MS─EVICE, MS╘YPE )
JMP MS─ELETE ;( WRITE─IRENT )
JMP MS╞ORMAT ;( MS─EVICE, MS╘YPE, .┴=LOW/HIGH─ENSITY )
JMP MS┬YTES╞REE ;( ) : .┴┘╪=BYTES╞REE
JMP CBM├OPY ;( .┴=IN╠FN, .╪=OUT╠FN )
JMP CBM─IRENT ;( .┴=LFN )
.BYTE $CB,133 ;IDENTIFICATION (LOCATION PK+30)
ERRNO .BUF 1
MS─EVICE .BUF 1
MS╘YPE .BUF 1 ;$00=1571, $FF=1581 OR ╞─-2000/4000
START├LUSTER .BUF 2
LEN═╠ .BUF 2 ;LENGTH MEDIUM AND LOW BYTES
WRITE─IRENT .BUF 2 ;POINTER TO DIRENT
CDIR┬LOCKS .BUF 2 ;CBM DIRENT BLOCKS
CDIR╘YPE .BUF 1 ;CBM DIRENT FILETYPE
CDIR╞LEN .BUF 1 ;CBM DIRENT FILENAME LENGTH
CDIR╬AME .BUF 16 ;CBM DIRENT FILENAME
;====GLOBAL DECLARAIONS====
KERNEL╠ISTEN = $FFB1
KERNEL╙ECOND = $FF93
KERNEL╒NLSN = $FFAE
KERNEL┴CPTR = $FFA2
KERNEL├IOUT = $FFA8
KERNEL╙PINP = $FF47
KERNEL├HKIN = $FFC6
KERNEL├HKOUT = $FFC9
KERNEL├LRCHN = $FFCC
KERNEL├HRIN = $FFCF
KERNEL├HROUT = $FFD2
ST = $90
CIA├LOCK = $DD00
CIA╞LAGS = $DC0D
CIA─ATA = $DC0C
CLUSTER┬LOCK├OUNT .BUF 1 ;1 OR 2
FAT┬LOCKS .BUF 1 ;UP TO 9
ROOT─IR┬LOCKS .BUF 1 ;UP TO 14
ROOT─IR┼NTRIES .BUF 1 ;UP TO 224
TOTAL╙ECTORS .BUF 2 ;UP TO 2880
FIRST╞ILE┬LOCK .BUF 1
FIRST╥OOT─IR┬LOCK .BUF 1
FILE├LUSTER├OUNT .BUF 2
LAST╞AT┼NTRY .BUF 2
BUF├YLINDER .BUF 1
BUF╙IDE .BUF 1
FAT─IRTY .BUF 1
DIR─IRTY .BUF 14 ;FLAG FOR EACH DIRECTORY BLOCK
FORMAT╨ARMS .BUF 1
SECTORS╨ER╘RACK .BYTE 9 ;DEFAULT, UP TO 18
.BUF 4
SECTORS╨ER├YL .BYTE 18 ;DEFAULT, UP TO 36
;====TEST ROUTINES====
MS╞ORMAT = *
LDA #$0E
STA $FF00
JSR MOUNT─ISK
LDA #0 ;CYLINDER
LDX #0 ;SIDE
JSR READ╘RACK
LDA #<TRACKBUF
LDY #>TRACKBUF
STA 1024
STY 1025
RTS
;====HARDWARE LEVEL====
SEND╒0 = * ;( .┴=BURST├OMMAND├ODE ) : .├╙=ERR
PHA
LDA #0
STA ST
LDA MS─EVICE
JSR KERNEL╠ISTEN
LDA #$6F
JSR KERNEL╙ECOND
LDA #"U"
JSR KERNEL├IOUT
BIT ST
BMI SEND╒0┼RROR
LDA #"0"
JSR KERNEL├IOUT
PLA
JSR KERNEL├IOUT
BIT ST
BMI SEND╒0┼RROR
CLC
RTS
SEND╒0┼RROR = *
LDA #5
STA ERRNO
SEC
RTS
TOGGLE├LOCK = *
LDA CIA├LOCK
EOR #$10
STA CIA├LOCK
RTS
SERIAL╫AIT = *
LDA #$08
- BIT CIA╞LAGS
BEQ -
RTS
GET┬URST┬YTE = *
JSR SERIAL╫AIT
LDX CIA─ATA
JSR TOGGLE├LOCK
TXA
RTS
MOUNT─ISK = * ;() : .├╙=ERR
LDA #%00011010
JSR SEND╒0
BCC +
RTS
+ JSR KERNEL╒NLSN
BIT ST
BMI SEND╒0┼RROR
CLC
JSR KERNEL╙PINP
BIT CIA╞LAGS
JSR TOGGLE├LOCK
JSR GET┬URST┬YTE
AND #$0F
STA ERRNO
CMP #2
BCS MOUNT┼XIT
LDY #0
- JSR GET┬URST┬YTE
STA FORMAT╨ARMS,Y
INY
CPY #6
BCC -
LDA SECTORS╨ER╘RACK
ASL
STA SECTORS╨ER├YL
;** SET INTERLEAVE TO 4 IF 1571, DON'T BOTHER FOR OTHER DRIVES
BIT MS╘YPE
BMI MOUNT┼XIT
LDA #%00001000
JSR SEND╒0
BCC +
RTS
+ LDA #4
JSR KERNEL├IOUT
JSR KERNEL╒NLSN
MOUNT┼XIT = *
RTS
BUFPTR = 2
SECNUM = 4
READ╘RACK = * ;( .┴=CYLINDER, .╪=SIDE ) : TRACKBUF, .├╙=ERR
PHA
TXA
AND #$01
ASL
ASL
ASL
ASL
BIT MS╘YPE
BPL +
EOR #$10
+ JSR SEND╒0
PLA
BCC +
RTS
+ JSR KERNEL├IOUT ;CYLINDER NUMBER
LDA #1 ;START SECTOR NUMBER
JSR KERNEL├IOUT
LDA SECTORS╨ER╘RACK ;SECTOR COUNT
JSR KERNEL├IOUT
JSR KERNEL╒NLSN
SEI
CLC
JSR KERNEL╙PINP
BIT CIA╞LAGS
JSR TOGGLE├LOCK
LDA #<TRACKBUF
LDY #>TRACKBUF
STA BUFPTR+0
STY BUFPTR+1
LDA #0
STA SECNUM
- BIT MS╘YPE
BMI +
JSR GET1571┬UF╨TR
+ JSR READ╙ECTOR
BCS TRACK┼XIT
INC SECNUM
LDA SECNUM
CMP SECTORS╨ER╘RACK
BCC -
CLC
JSR TOGGLE├LOCK ;%%%
TRACK┼XIT = *
CLI
RTS
GET1571┬UF╨TR = *
LDA #<TRACKBUF
STA BUFPTR
LDX SECNUM
CLC
LDA #>TRACKBUF
ADC BUFPTR1571,X
STA BUFPTR+1
RTS
BUFPTR1571 = *
.BYTE 0,8,16,6,14,4,12,2,10
READ╙ECTOR = * ;( BUFPTR ) : .├╙=ERR
JSR GET┬URST┬YTE
AND #$0F
STA ERRNO
CMP #2
BCC +
RTS
+ LDX #2
LDY #0
READ┬YTE = *
LDA #$08
- BIT CIA╞LAGS
BEQ -
LDA CIA├LOCK
EOR #$10
STA CIA├LOCK
LDA CIA─ATA
STA (BUFPTR),Y
INY
BNE READ┬YTE
INC BUFPTR+1
DEX
BNE READ┬YTE
RTS
OLD├LOCK = 5
WRITE╙ECTOR = * ;( BUFPTR, .┴=CYLINDER, .╪=SIDE, .┘=SECTOR ) : .├╙=ERR
PHA
STY SECNUM
TXA
AND #$01
ASL
ASL
ASL
ASL
ORA #$02
BIT MS╘YPE
BPL +
EOR #$10
+ JSR SEND╒0
PLA
BCC +
RTS
+ JSR KERNEL├IOUT ;TRACK NUMBER
LDA SECNUM ;SECTOR NUMBER
JSR KERNEL├IOUT
LDA #1 ;SECTOR COUNT
JSR KERNEL├IOUT
JSR KERNEL╒NLSN
SEI
LDA #$40
STA OLD├LOCK
SEC
JSR KERNEL╙PINP ;SET FOR BURST OUTPUT
SEI
BIT CIA╞LAGS
LDX #2
LDY #0
WRITE┬YTE = *
LDA CIA├LOCK
CMP CIA├LOCK
BNE WRITE┬YTE
EOR OLD├LOCK
AND #$40
BEQ WRITE┬YTE
LDA (BUFPTR),Y
STA CIA─ATA
LDA OLD├LOCK
EOR #$40
STA OLD├LOCK
LDA #8
- BIT CIA╞LAGS
BEQ -
INY
BNE WRITE┬YTE
INC BUFPTR+1
DEX
BNE WRITE┬YTE
CLC
JSR KERNEL╙PINP
BIT CIA╞LAGS
JSR TOGGLE├LOCK
JSR SERIAL╫AIT
LDX CIA─ATA
JSR TOGGLE├LOCK
TXA
AND #$0F
STA ERRNO
CMP #2
CLI
RTS
;====LOGICAL SECTOR LEVEL====
INIT╨ACKAGE = *
LDA #$0E
STA $FF00
LDA #$FF
STA BUF├YLINDER
STA BUF╙IDE
LDX #13
- STA DIR─IRTY,X
DEX
BPL -
STA FAT─IRTY
CLC
RTS
SECTOR╙AVE = 5
READ┬LOCK = * ;( .┴=CYLINDER,.╪=SIDE,.┘=SECTOR ) : .┴┘=BLK╨TR,.├╙=ERR
CMP BUF├YLINDER
BNE READ┬LOCK╨HYSICAL
CPX BUF╙IDE
BNE READ┬LOCK╨HYSICAL
DEY
TYA
ASL
CLC
ADC #>TRACKBUF
TAY
LDA #<TRACKBUF
CLC
RTS
READ┬LOCK╨HYSICAL = *
STA BUF├YLINDER
STX BUF╙IDE
STY SECTOR╙AVE
JSR READ╘RACK
BCC READ┬LOCK╨HYSICAL╧K
LDA ERRNO
AND #$0F
CMP #11 ;DISK CHANGE
BEQ +
- LDA #$FF
STA BUF├YLINDER
STX BUF╙IDE
SEC
RTS
+ JSR MOUNT─ISK
LDA BUF├YLINDER
LDX BUF╙IDE
LDY SECTOR╙AVE
BCC READ┬LOCK╨HYSICAL
JMP -
READ┬LOCK╨HYSICAL╧K = *
LDA BUF├YLINDER
LDX BUF╙IDE
LDY SECTOR╙AVE
JMP READ┬LOCK
DIVIDE┬Y├YL╙ECS = * ;( .┴┘=NUMBER ) : .┴=QUOTIENT, .┘=REMAINDER
LDX #$FF
- INX
SEC
SBC SECTORS╨ER├YL
BCS -
DEY
BPL -
CLC
ADC SECTORS╨ER├YL
INY
TAY
TXA
RTS
CONVERT╠OGICAL┬LOCK╬UM = * ;( .┴┘=BLOCK╬UM ) : .┴=CYL, .╪=SIDE, .┘=SEC
JSR DIVIDE┬Y├YL╙ECS
LDX #0
CPY SECTORS╨ER╘RACK
BCC +
PHA
TYA
SBC SECTORS╨ER╘RACK
TAY
PLA
LDX #1
+ INY
RTS
DEST╨TR = 6
CUR├YLINDER = 8
CUR╙IDE = 9
CUR╙ECTOR = 10
BLOCK├OUNTDOWN = 11
SOURCE╨TR = 12
COPY┬LOCKS = * ;( .┴┘=START┬LOCK, .╪=BLOCK├OUNT, ($6)=DEST ) : .├╙=ERR
STX BLOCK├OUNTDOWN
JSR CONVERT╠OGICAL┬LOCK╬UM
STA CUR├YLINDER
STX CUR╙IDE
STY CUR╙ECTOR
COPY┬LOCK╠OOP = *
LDA CUR├YLINDER
LDX CUR╙IDE
LDY CUR╙ECTOR
JSR READ┬LOCK
BCC +
RTS
+ STA SOURCE╨TR+0
STY SOURCE╨TR+1
LDX #2
LDY #0
- LDA (SOURCE╨TR),Y
STA (DEST╨TR),Y
INY
LDA (SOURCE╨TR),Y
STA (DEST╨TR),Y
INY
BNE -
INC SOURCE╨TR+1
INC DEST╨TR+1
DEX
BNE -
INC CUR╙ECTOR
LDA CUR╙ECTOR
CMP SECTORS╨ER╘RACK
BEQ +
BCC +
LDA #1
STA CUR╙ECTOR
INC CUR╙IDE
LDA CUR╙IDE
CMP #2
BCC +
LDA #0
STA CUR╙IDE
INC CUR├YLINDER
+ DEC BLOCK├OUNTDOWN
BNE COPY┬LOCK╠OOP
CLC
RTS
CONVERT├LUSTER╬UM = * ;( .┴┘=CLUSTER╬UM ) : .┴┘=LOGICAL┬LOCK╬UM
SEC
SBC #2
BCS +
DEY
+ LDX CLUSTER┬LOCK├OUNT
CPX #1
BEQ +
ASL
STY 7
ROL 7
LDY 7
+ CLC
ADC FIRST╞ILE┬LOCK
BCC +
INY
+ RTS
READ├LUSTER = * ;( .┴┘=CLUSTER╬UMBER ) : CLUSTER┬UF, .├╙=ERR
JSR CONVERT├LUSTER╬UM
;** READ LOGICAL BLOCKS COMPRISING CLUSTER
LDX #<CLUSTER┬UF
STX 6
LDX #>CLUSTER┬UF
STX 7
LDX CLUSTER┬LOCK├OUNT
JMP COPY┬LOCKS
WRITE╠OGICAL┬LOCK = * ;( .┴┘=LOGICAL┬LOCK╬UMBER, BUFPTR ) : .├╙=ERR
JSR CONVERT╠OGICAL┬LOCK╬UM
CMP BUF├YLINDER
BNE +
CPX BUF╙IDE
BNE +
PHA
LDA #$FF
STA BUF├YLINDER
STA BUF╙IDE
PLA
+ JSR WRITE╙ECTOR
RTS
WRITE├LUSTER╙AVE .BUF 2
WRITE├LUSTER = * ;( .┴┘=CLUSTER╬UMBER, CLUSTER┬UF ) : .├╙=ERR
JSR CONVERT├LUSTER╬UM
LDX #<CLUSTER┬UF
STX BUFPTR+0
LDX #>CLUSTER┬UF
STX BUFPTR+1
STA WRITE├LUSTER╙AVE+0
STY WRITE├LUSTER╙AVE+1
JSR WRITE╠OGICAL┬LOCK
BCC +
RTS
+ LDA CLUSTER┬LOCK├OUNT
CMP #2
BCS +
RTS
+ LDA WRITE├LUSTER╙AVE+0
LDY WRITE├LUSTER╙AVE+1
CLC
ADC #1
BCC +
INY
+ JSR WRITE╠OGICAL┬LOCK
RTS
;====═╙-─╧╙ FORMAT LEVEL====
BOOT┬LOCK = 2
MS─IR = * ;( ) : .┴┘=DIRBUF, .╪=DIR┼NTRIES, .├╙=ERR
LDA #$0E
STA $FF00
;** GET PARAMETERS FROM BOOT SECTOR
LDA #0
LDY #0
JSR CONVERT╠OGICAL┬LOCK╬UM
JSR READ┬LOCK
BCC +
RTS
+ STA BOOT┬LOCK+0
STY BOOT┬LOCK+1
LDY #13 ;GET CLUSTER SIZE
LDA (BOOT┬LOCK),Y
STA CLUSTER┬LOCK├OUNT
CMP #3
BCC +
INVALID╨ARMS = *
LDA #$FF
STA ERRNO
SEC
RTS
+ LDY #16 ;CHECK ╞┴╘ REPLICATION COUNT, MUST BE 2
LDA (BOOT┬LOCK),Y
CMP #2
BNE INVALID╨ARMS
LDY #22 ;GET ╞┴╘ SIZE IN SECTORS, MAX OF 9
LDA (BOOT┬LOCK),Y
STA FAT┬LOCKS
CMP #10
BCS INVALID╨ARMS
LDY #17 ;GET DIRECTORY SIZE
LDA (BOOT┬LOCK),Y
STA ROOT─IR┼NTRIES
CMP #225
BCS INVALID╨ARMS
LSR
LSR
LSR
LSR
STA ROOT─IR┬LOCKS
LDY #19 ;GET TOTAL SECTOR COUNT
LDA (BOOT┬LOCK),Y
STA TOTAL╙ECTORS+0
INY
LDA (BOOT┬LOCK),Y
STA TOTAL╙ECTORS+1
LDY #24 ;CHECK SECTORS PER TRACK, MUST BE 18 OR FEWER
LDA (BOOT┬LOCK),Y
CMP #19
BCS INVALID╨ARMS
LDY #26
LDA (BOOT┬LOCK),Y
CMP #2 ;CHECK NUMBER OF SIDES, MUST BE 2
BNE INVALID╨ARMS
LDY #14 ;CHECK NUMBER OF BOOT SECTORS, MUST BE 1
LDA (BOOT┬LOCK),Y
CMP #1
BNE INVALID╨ARMS
;** GET DERIVED PARAMETERS
LDA FAT┬LOCKS ;FIRST ROOT DIRECTORY SECTOR
ASL
CLC
ADC #1
STA FIRST╥OOT─IR┬LOCK
CLC ;FIRST FILE SECTOR
ADC ROOT─IR┬LOCKS
STA FIRST╞ILE┬LOCK
LDA TOTAL╙ECTORS+0 ;NUMBER OF FILE CLUSTERS
LDY TOTAL╙ECTORS+1
SEC
SBC FIRST╞ILE┬LOCK
BCS +
DEY
+ STA FILE├LUSTER├OUNT+0
STY FILE├LUSTER├OUNT+1
LDA CLUSTER┬LOCK├OUNT
CMP #2
BNE +
LSR FILE├LUSTER├OUNT+1
ROR FILE├LUSTER├OUNT+0
+ CLC
LDA FILE├LUSTER├OUNT+0
ADC #2
STA LAST╞AT┼NTRY+0
LDA FILE├LUSTER├OUNT+1
ADC #0
STA LAST╞AT┼NTRY+1
;** LOAD ╞┴╘
LDA #<FATBUF
LDY #>FATBUF
STA 6
STY 7
LDA #1
LDY #0
LDX FAT┬LOCKS
JSR COPY┬LOCKS
BCC +
RTS
;** LOAD ACTUAL DIRECTORY
+ LDA #<DIRBUF
LDY #>DIRBUF
STA 6
STY 7
LDA FIRST╥OOT─IR┬LOCK
LDY #0
LDX ROOT─IR┬LOCKS
JSR COPY┬LOCKS
BCC +
RTS
+ LDA #<DIRBUF
LDY #>DIRBUF
LDX ROOT─IR┼NTRIES
CLC
RTS
ENTRY┴DDR = 2
ENTRY╫ORK = 4
ENTRY┬ITS = 5
ENTRY─ATA0 = 6
ENTRY─ATA1 = 7
ENTRY─ATA2 = 8
LOCATE╞AT┼NTRY = * ;( .┴┘=FAT┼NTRY╬UMBER ) : ENTRY┴DDR, ENTRY┬ITS1
STA ENTRY┬ITS
;** DIVIDE BY TWO
STY ENTRY┴DDR+1
LSR ENTRY┴DDR+1
ROR
;** TIMES THREE
STA ENTRY╫ORK
LDX ENTRY┴DDR+1
ASL
ROL ENTRY┴DDR+1
CLC
ADC ENTRY╫ORK
STA ENTRY┴DDR
TXA
ADC ENTRY┴DDR+1
STA ENTRY┴DDR+1
;** ADD BASE, GET DATA
CLC
LDA ENTRY┴DDR
ADC #<FATBUF
STA ENTRY┴DDR
LDA ENTRY┴DDR+1
ADC #>FATBUF
STA ENTRY┴DDR+1
LDY #2
- LDA (ENTRY┴DDR),Y
STA ENTRY─ATA0,Y
DEY
BPL -
RTS
GET╞AT┼NTRY = * ;( .┴┘=FAT┼NTRY╬UMBER ) : .┴┘=FAT┼NTRY╓ALUE
JSR LOCATE╞AT┼NTRY
LDA ENTRY┬ITS
AND #1
BNE +
;** CASE 1: FIRST 12-BIT CLUSTER
LDA ENTRY─ATA1
AND #$0F
TAY
LDA ENTRY─ATA0
RTS
;** CASE 2: SECOND 12-BIT CLUSTER
+ LDA ENTRY─ATA1
LDX #4
- LSR ENTRY─ATA2
ROR
DEX
BNE -
LDY ENTRY─ATA2
RTS
FAT╓ALUE = 9
SET╞AT┼NTRY = * ;( .┴┘=FAT┼NTRY╬UMBER, (FAT╓ALUE) )
JSR LOCATE╞AT┼NTRY
LDA FAT╓ALUE+1
AND #$0F
STA FAT╓ALUE+1
LDA ENTRY┬ITS
AND #1
BNE +
;** CASE 1: FIRST 12-BIT CLUSTER
LDA FAT╓ALUE
STA ENTRY─ATA0
LDA ENTRY─ATA1
AND #$F0
ORA FAT╓ALUE+1
STA ENTRY─ATA1
JMP SET╞AT┼XIT
;** CASE 2: SECOND 12-BIT CLUSTER
+ LDX #4
- ASL FAT╓ALUE
ROL FAT╓ALUE+1
DEX
BNE -
LDA FAT╓ALUE+1
STA ENTRY─ATA2
LDA ENTRY─ATA1
AND #$0F
ORA FAT╓ALUE
STA ENTRY─ATA1
SET╞AT┼XIT = *
LDY #2
- LDA ENTRY─ATA0,Y
STA (ENTRY┴DDR),Y
DEY
BPL -
STY FAT─IRTY
RTS
DIRTY─IRENT = * ;( WRITE─IRENT )
SEC
LDA WRITE─IRENT+0
SBC #<DIRBUF
LDA WRITE─IRENT+1
SBC #>DIRBUF
LSR
AND #$0F
TAX
LDA #$FF
STA DIR─IRTY,X
RTS
DEL├LUSTER = 14
MS─ELETE = * ;( WRITE─IRENT )
LDY #$0E
STY $FF00
LDA WRITE─IRENT+0
LDY WRITE─IRENT+1
STA 2
STY 3
LDA #$E5
LDY #0
STA (2),Y
LDY #26
LDA (2),Y
STA DEL├LUSTER+0
INY
LDA (2),Y
STA DEL├LUSTER+1
- LDA DEL├LUSTER+1
CMP #12 ;CLUSTER NUMBER HIGH BYTE
BCC +
JMP DIRTY─IRENT
+ TAY
LDA DEL├LUSTER
JSR GET╞AT┼NTRY
PHA
TYA
PHA
LDA #0
STA FAT╓ALUE+0
STA FAT╓ALUE+1
LDA DEL├LUSTER+0
LDY DEL├LUSTER+1
JSR SET╞AT┼NTRY
PLA
STA DEL├LUSTER+1
PLA
STA DEL├LUSTER
JMP -
FLUSH┬LOCK = 14
FLUSH├OUNTDOWN = $60
FLUSH╥EPEATS = $61
FLUSH─IR╔NDEX = $61
MS╞LUSH = * ;( MS─EVICE, MS╘YPE ) : .├╙=ERROR
LDA #$0E
STA $FF00
LDA FAT─IRTY
BEQ FLUSH─IRECTORY
LDA #0
STA FAT─IRTY
;** FLUSH FAT
LDA #2
STA FLUSH╥EPEATS
LDA #1
STA FLUSH┬LOCK
MASTER╞LUSH = *
LDA FAT┬LOCKS
STA FLUSH├OUNTDOWN
LDA #<FATBUF
LDY #>FATBUF
STA BUFPTR
STY BUFPTR+1
- LDA FLUSH┬LOCK
LDY #0
JSR WRITE╠OGICAL┬LOCK
BCC +
RTS
+ INC FLUSH┬LOCK
DEC FLUSH├OUNTDOWN
BNE -
DEC FLUSH╥EPEATS
BNE MASTER╞LUSH
;** FLUSH DIRECTORY
FLUSH─IRECTORY = *
LDA FIRST╥OOT─IR┬LOCK
STA FLUSH┬LOCK
LDA ROOT─IR┬LOCKS
STA FLUSH├OUNTDOWN
LDA #0
STA FLUSH─IR╔NDEX
LDA #<DIRBUF
LDY #>DIRBUF
STA BUFPTR+0
STY BUFPTR+1
- LDX FLUSH─IR╔NDEX
LDA DIR─IRTY,X
BEQ +
LDA #0
STA DIR─IRTY,X
LDA FLUSH┬LOCK
LDY #0
JSR WRITE╠OGICAL┬LOCK
DEC BUFPTR+1
DEC BUFPTR+1
+ INC FLUSH┬LOCK
INC FLUSH─IR╔NDEX
INC BUFPTR+1
INC BUFPTR+1
DEC FLUSH├OUNTDOWN
BNE -
CLC
RTS
BF╞AT┼NTRY = 14
BF┬LOCKS = $60
MS┬YTES╞REE = * ;( ) : .┴┘╪=FILE┬YTES╞REE
LDY #$0E
STY $FF00
LDA #2
LDY #0
STA BF╞AT┼NTRY+0
STY BF╞AT┼NTRY+1
STY BF┬LOCKS+0
STY BF┬LOCKS+1
- LDA BF╞AT┼NTRY+0
LDY BF╞AT┼NTRY+1
JSR GET╞AT┼NTRY
STY 2
ORA 2
BNE +
INC BF┬LOCKS+0
BNE +
INC BF┬LOCKS+1
+ INC BF╞AT┼NTRY
BNE +
INC BF╞AT┼NTRY+1
+ LDA BF╞AT┼NTRY+0
CMP LAST╞AT┼NTRY+0
LDA BF╞AT┼NTRY+1
SBC LAST╞AT┼NTRY+1
BCC -
LDX CLUSTER┬LOCK├OUNT
- ASL BF┬LOCKS
ROL BF┬LOCKS+1
DEX
BNE -
LDA #0
LDY BF┬LOCKS+0
LDX BF┬LOCKS+1
RTS
;====FILE COPY LEVEL====
TRANS═ODE = 14
LFN = 15
CBM─ATA╨TR = $60
CBM─ATA╠EN = $62
CLUSTER = $64
COPY╞ILE├LUSTER = * ;( CLUSTER, LFN, TRANS═ODE ) : .├╙=ERR
LDA CLUSTER+0
LDY CLUSTER+1
JSR READ├LUSTER
BCC +
RTS
+ LDA #<CLUSTER┬UF
LDY #>CLUSTER┬UF
STA CBM─ATA╨TR+0
STY CBM─ATA╨TR+1
LDA #0
STA CBM─ATA╠EN+0
LDA CLUSTER┬LOCK├OUNT
ASL
STA CBM─ATA╠EN+1
;**GET NEXT CLUSTER
LDA CLUSTER+0
LDY CLUSTER+1
JSR GET╞AT┼NTRY
STA CLUSTER+0
STY CLUSTER+1
CPY #12 ;CLUSTER NUMBER HIGH BYTE
BCC COPY╞ILE├LUSTER─ATA
LDA LEN═╠
STA CBM─ATA╠EN
LDA #$01
LDX CLUSTER┬LOCK├OUNT
CPX #1
BEQ +
LDA #$03
+ AND LEN═╠+1
BNE +
LDX LEN═╠
BEQ COPY╞ILE├LUSTER─ATA
+ STA CBM─ATA╠EN+1
COPY╞ILE├LUSTER─ATA = *
JSR COMMIE╧UT
RTS
CBM─ATA╠IMIT = $66
COMMIE╧UT = * ;( CBM─ATA╨TR, CBM─ATA╠EN ) : .├╙=ERR
LDX LFN
BNE +
CLC
RTS
+ JSR KERNEL├HKOUT
BCC COMMIE╧UT═ORE
STA ERRNO
RTS
COMMIE╧UT═ORE = *
LDA #255
LDX CBM─ATA╠EN+1
BNE +
LDA CBM─ATA╠EN
+ STA CBM─ATA╠IMIT
LDY #0
- LDA (CBM─ATA╨TR),Y
BIT TRANS═ODE
BPL +
TAX
LDA TRANS┬UF,X
BEQ COMMIE╬EXT
+ JSR KERNEL├HROUT
COMMIE╬EXT = *
INY
CPY CBM─ATA╠IMIT
BNE -
CLC
LDA CBM─ATA╨TR
ADC CBM─ATA╠IMIT
STA CBM─ATA╨TR
BCC +
INC CBM─ATA╨TR+1
+ SEC
LDA CBM─ATA╠EN
SBC CBM─ATA╠IMIT
STA CBM─ATA╠EN
BCS +
DEC CBM─ATA╠EN+1
+ LDA CBM─ATA╠EN
ORA CBM─ATA╠EN+1
BNE COMMIE╧UT═ORE
JSR KERNEL├LRCHN
CLC
RTS
MS╥EAD = * ;( CLUSTER, LEN═╠, .┴=TRANS═ODE, .╪=LFN ) : .├╙=ERR
LDY #$0E
STY $FF00
STA TRANS═ODE
STX LFN
LDA START├LUSTER+0
LDY START├LUSTER+1
STA CLUSTER+0
STY CLUSTER+1
JMP +
- JSR COPY╞ILE├LUSTER
BCC +
RTS
+ LDA CLUSTER+1
CMP #12 ;CLUSTER NUMBER HIGH BYTE
BCC -
CLC
RTS
IN╠FN = $50
GENERATE╠F = $51
CBM─ATA═AX = $52
REACHED┼OF = $54
PREV╙T = $55
COMMIE╔N╔NIT = * ;( .┴=TRANS═ODE, .╪=IN╠FN )
STA TRANS═ODE
STX IN╠FN
LDA #0
STA GENERATE╠F
STA REACHED┼OF
STA PREV╙T
RTS
COMMIE╔N = * ;( CBM─ATA╨TR++, CBM─ATA═AX ) : CBM─ATA╠EN, .├╙=ERR, .┌=EOF
LDA #0
STA CBM─ATA╠EN
STA CBM─ATA╠EN+1
LDX REACHED┼OF
BEQ +
LDA #0
CLC
RTS
+ LDX IN╠FN
JSR KERNEL├HKIN
BCC COMMIE╔N═ORE
STA ERRNO
RTS
COMMIE╔N═ORE = *
LDA #255
LDX CBM─ATA═AX+1
BNE +
LDA CBM─ATA═AX
+ STA CBM─ATA╠IMIT
LDY #0
- JSR COMMIE╔N┬YTE
BCC +
RTS
+ BEQ +
STA (CBM─ATA╨TR),Y
INY
CPY CBM─ATA╠IMIT
BNE -
+ STY CBM─ATA╠IMIT
CLC
LDA CBM─ATA╨TR
ADC CBM─ATA╠IMIT
STA CBM─ATA╨TR
BCC +
INC CBM─ATA╨TR+1
+ CLC
LDA CBM─ATA╠EN
ADC CBM─ATA╠IMIT
STA CBM─ATA╠EN
BCC +
INC CBM─ATA╠EN+1
+ SEC
LDA CBM─ATA═AX
SBC CBM─ATA╠IMIT
STA CBM─ATA═AX
BCS +
DEC CBM─ATA═AX+1
+ LDA REACHED┼OF
BNE +
LDA CBM─ATA═AX
ORA CBM─ATA═AX+1
BNE COMMIE╔N═ORE
+ JSR KERNEL├LRCHN
LDA CBM─ATA╠EN
ORA CBM─ATA╠EN+1
CLC
RTS
COMMIE╔N┬YTE = * ;( ) : .┴=CHAR, .├╙=ERR, .┌=EOF, REACHED┼OF
;** CHECK FOR ALREADY PAST EOF
LDA REACHED┼OF
BEQ +
BRK
;** CHECK FOR GENERATED LINEFEED
+ LDA GENERATE╠F
BEQ +
LDA #0
STA GENERATE╠F
LDA #$0A
CLC
RTS
;** CHECK FOR EOF
+ LDA PREV╙T
AND #$40
BEQ +
LDA #$FF
STA REACHED┼OF
LDA #0
CLC
RTS
;** READ ACTUAL CHARACTER
+ JSR KERNEL├HRIN
LDX ST
STX PREV╙T
BCC +
STA ERRNO
JSR KERNEL├LRCHN
RTS
;** TRANSLATE IF NECESSARY
+ BIT TRANS═ODE
BPL +
TAX
LDA TRANS┬UF╘O┴SCII,X
BEQ COMMIE╔N┬YTE
CMP #$0D
BNE +
STA GENERATE╠F
;** EXIT
+ LDX #$FF
CLC
RTS
FIRST╞REE╞AT┼NTRY = $5A
ALLOCATE╞AT┼NTRY = * ;( ) : .┴┘=FAT┼NTRY, .├╙=ERR
- LDA FIRST╞REE╞AT┼NTRY
CMP LAST╞AT┼NTRY
LDA FIRST╞REE╞AT┼NTRY+1
SBC LAST╞AT┼NTRY+1
BCC +
RTS
+ LDA FIRST╞REE╞AT┼NTRY
LDY FIRST╞REE╞AT┼NTRY+1
JSR GET╞AT┼NTRY
STY 2
ORA 2
BNE +
LDA FIRST╞REE╞AT┼NTRY
LDY FIRST╞REE╞AT┼NTRY+1
CLC
RTS
+ INC FIRST╞REE╞AT┼NTRY
BNE -
INC FIRST╞REE╞AT┼NTRY+1
JMP -
MS╞ILE╠ENGTH = $5C ;(3 BYTES)
MS╫RITE├LUSTER = * ; (*) : .├╙=ERR
;** GET A NEW CLUSTER
JSR ALLOCATE╞AT┼NTRY
BCC +
RTS
;** MAKE PREVIOUS FAT ENTRY POINT TO NEW CLUSTER
+ STA FAT╓ALUE
STY FAT╓ALUE+1
LDA CLUSTER
ORA CLUSTER+1
BEQ +
LDA CLUSTER
LDY CLUSTER+1
LDX FAT╓ALUE
STX CLUSTER
LDX FAT╓ALUE+1
STX CLUSTER+1
JSR SET╞AT┼NTRY
JMP MS├LUSTER╬EW
+ LDA WRITE─IRENT
LDY WRITE─IRENT+1
STA 2
STY 3
LDY #26
LDA FAT╓ALUE
STA (2),Y
STA CLUSTER
INY
LDA FAT╓ALUE+1
STA (2),Y
STA CLUSTER+1
;** MAKE NEW FAT ENTRY POINT TO NULL
MS├LUSTER╬EW = *
LDA #$FF
LDY #$0F
STA FAT╓ALUE
STY FAT╓ALUE+1
LDA CLUSTER
LDY CLUSTER+1
JSR SET╞AT┼NTRY
;** WRITE NEW CLUSTER DATA
+ LDA CLUSTER
LDY CLUSTER+1
JSR WRITE├LUSTER
BCC +
RTS
;** ADD CLUSTER LENGTH TO FILE LENGTH
+ CLC
LDA MS╞ILE╠ENGTH
ADC CBM─ATA╠EN
STA MS╞ILE╠ENGTH
LDA MS╞ILE╠ENGTH+1
ADC CBM─ATA╠EN+1
STA MS╞ILE╠ENGTH+1
BCC +
INC MS╞ILE╠ENGTH+2
+ CLC
RTS
MS╫RITE = * ;( MS─EVICE, MS╘YPE, WRITE─IRENT, .┴=TRANS, .╪=CBM╠FN ) :.├╙=ERR
LDY #$0E
STY $FF00
;** INITIALIZE
JSR COMMIE╔N╔NIT
LDA #0
STA CLUSTER
STA CLUSTER+1
STA FIRST╞REE╞AT┼NTRY+1
STA MS╞ILE╠ENGTH
STA MS╞ILE╠ENGTH+1
STA MS╞ILE╠ENGTH+2
LDA #2
STA FIRST╞REE╞AT┼NTRY
;** COPY CLUSTER FROM CBM FILE
- LDA #<CLUSTER┬UF
LDY #>CLUSTER┬UF
STA CBM─ATA╨TR
STY CBM─ATA╨TR+1
LDA CLUSTER┬LOCK├OUNT
ASL
TAY
LDA #0
STA CBM─ATA═AX
STY CBM─ATA═AX+1
JSR COMMIE╔N
BCC +
RTS
+ BEQ +
JSR MS╫RITE├LUSTER
BCC -
RTS
;** WRAP UP AFTER WRITING - SET FILE LENGTH, DIRTY FLAG, EXIT.
+ LDA WRITE─IRENT
LDY WRITE─IRENT+1
STA 2
STY 3
LDX #0
LDY #28
- LDA MS╞ILE╠ENGTH,X
STA (2),Y
INY
INX
CPX #3
BCC -
JSR DIRTY─IRENT
CLC
RTS
;===== COMMODORE FILE LEVEL =====
CBM├OPY = * ;( .┴=IN╠FN, .╪=OUT╠FN )
LDY #$0E
STY $FF00
STX LFN
TAX
LDA #0
JSR COMMIE╔N╔NIT
- LDA #<CLUSTER┬UF
LDY #>CLUSTER┬UF
STA CBM─ATA╨TR
STY CBM─ATA╨TR+1
LDA #<1024
LDY #>1024
STA CBM─ATA═AX
STY CBM─ATA═AX+1
JSR COMMIE╔N
BCS +
BEQ +
LDA #<CLUSTER┬UF
LDY #>CLUSTER┬UF
STA CBM─ATA╨TR
STY CBM─ATA╨TR+1
JSR COMMIE╧UT
BCS +
JMP -
+ RTS
CBM─IRENT = * ;( .┴=LFN )
LDY #$0E
STY $FF00
TAX
JSR KERNEL├HKIN
BCC +
CDIR┼RR = *
LDA #0
STA CDIR╞LEN
STA CDIR┬LOCKS
STA CDIR┬LOCKS+1
RTS
;** GET BLOCK COUNT
+ JSR CDIR╟ETCH
JSR CDIR╟ETCH
JSR CDIR╟ETCH
STA CDIR┬LOCKS
JSR CDIR╟ETCH
STA CDIR┬LOCKS+1
;** LOOK FOR FILENAME
LDA #0
STA CDIR╞LEN
- JSR CDIR╟ETCH
CMP #34
BEQ +
CMP #"B"
BNE -
JSR KERNEL├LRCHN
RTS
;** GET FILENAME
+ LDY #0
- JSR CDIR╟ETCH
CMP #34
BEQ +
STA CDIR╬AME,Y
INY
BNE -
+ STY CDIR╞LEN
- JSR CDIR╟ETCH
CMP #" "
BEQ -
STA CDIR╘YPE
- JSR CDIR╟ETCH
CMP #0
BNE -
JSR KERNEL├LRCHN
RTS
CDIR╟ETCH = *
JSR KERNEL├HRIN
BCS +
BIT ST
BVS +
RTS
+ PLA
PLA
JSR KERNEL├LRCHN
JMP CDIR┼RR
;===== DATA =====
TRANS┬UF = *
;0 1 2 3 4 5 6 7 8 9 A B C D E F
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$14,$09,$0D,$00,$93,$00,$00,$00 ;0
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;1
.BYTE $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F ;2
.BYTE $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F ;3
.BYTE $40,$C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF ;4
.BYTE $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7,$D8,$D9,$DA,$5B,$5C,$5D,$5E,$5F ;5
.BYTE $C0,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E,$4F ;6
.BYTE $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5A,$DB,$DC,$DD,$DE,$DF ;7
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;8
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;9
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;A
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;B
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;C
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;D
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;E
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;F
TRANS┬UF╘O┴SCII = *
;0 1 2 3 4 5 6 7 8 9 A B C D E F
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$09,$00,$00,$00,$0D,$00,$00 ;0
.BYTE $00,$00,$00,$00,$08,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;1
.BYTE $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F ;2
.BYTE $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F ;3
.BYTE $40,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6A,$6B,$6C,$6D,$6E,$6F ;4
.BYTE $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7A,$5B,$5C,$5D,$5E,$5F ;5
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;6
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;7
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;8
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;9
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;A
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;B
.BYTE $60,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E,$4F ;C
.BYTE $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5A,$7B,$7C,$7D,$7E,$7F ;D
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ;E
.BYTE $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$7E ;F
;====BSS STORAGE (SIZE=22,016 BYTES)====
BSS = *
TRACKBUF = $6A00 ;(9216) ;ROOM FOR 18 X 512-BYTE SECTORS
CLUSTER┬UF = $8E00 ;(1024) ;2 SECTORS
FATBUF = $9200 ;(4608) ;9 SECTORS
DIRBUF = $A400 ;(7168) ;14 SECTORS = 224 DIRENTS